not-set behaviour of some attributes
I am working on the parameter loading code for svgfonts. Some attributes of the font-face tag are specified to behave in special ways when not set. One example is this couple of attribute:
accent-height = "<number>" The distance from the origin to the top of accent characters, measured by a distance within the font coordinate system. If the attribute is not specified, the effect is as if the attribute were set to the value of the ascent attribute. If this attribute is used, the units-per-em attribute must also be specified. Animatable: no. ascent = "<number>" Same syntax and semantics as the 'ascent' descriptor within an @font-face rule. The maximum unaccented height of the font within the font coordinate system. If the attribute is not specified, the effect is as if the attribute were set to the difference between the units- per-em value and the vert-origin-y value for the corresponding font. Animatable: no.
Is there already a established good practice to deal with this kind of thing on the inkscape codebase?
I suppose that a good solution would be to implement a container template-class which would take care of the set/unset state of the stored object (in these cases, a double) and a method to compute the nonset value, sometimes refering to the value of other objects. In these cases, it would refer to an ascent object for the computation of a not-set accent-height attribute and both vert-origin-y and units-per-em objects for the computation of a not-set ascent attribute.
Am I right? Does this already exist on the codebase? Should I implement it this way?
Juca
On Fri, May 9, 2008 at 8:26 AM, Felipe Sanches > Is there already a established good practice to deal with this kind of
thing on the inkscape codebase?
Not sure whether it's really good or not, but for CSS style properties, style.h defines a number of compound types which include the "set" flag. They also store separately the specified value and the computed value. So you probably can reuse SPIlength and similar structs in your code.
participants (2)
-
bulia byak
-
Felipe Sanches