gitlab#108 - Support font-size:larger and font-size:smaller

GNOME/librsvg#108
parent 4e83eb0b
......@@ -61,20 +61,39 @@ normalize_font_size (RsvgState * state, RsvgDrawingCtx * ctx)
switch (state->font_size.unit) {
case LENGTH_UNIT_PERCENT:
case LENGTH_UNIT_FONT_EM:
case LENGTH_UNIT_FONT_EX:
case LENGTH_UNIT_FONT_EX: {
double parent_size;
parent = rsvg_state_parent (state);
if (parent) {
double parent_size;
parent_size = normalize_font_size (parent, ctx);
return state->font_size.length * parent_size;
} else {
parent_size = 12.0;
}
break;
return state->font_size.length * parent_size;
}
case LENGTH_UNIT_RELATIVE_LARGER:
case LENGTH_UNIT_RELATIVE_SMALLER: {
double parent_size;
parent = rsvg_state_parent (state);
if (parent) {
parent_size = normalize_font_size (parent, ctx);
} else {
parent_size = 12.0;
}
if (state->font_size.unit == LENGTH_UNIT_RELATIVE_LARGER) {
return parent_size * 1.2;
} else {
return parent_size / 1.2;
}
}
default:
return rsvg_length_normalize (&state->font_size, ctx);
break;
}
return 12.;
}
double
......
......@@ -173,9 +173,10 @@ impl RsvgLength {
}
},
// FIXME: these are pending: https://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#propdef-font-size
LengthUnit::RelativeLarger |
LengthUnit::RelativeSmaller => { 0.0 }
LengthUnit::RelativeSmaller => {
drawing_ctx::get_normalized_font_size (draw_ctx)
},
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<title>Voronoi. Simple poor</title>
<style type="text/css">
<![CDATA[
.line {
stroke : black;
stroke-width : 1;
stroke-linecap : butt;
}
.circle {
stroke : none;
stroke-width : 0;
fill : black;
}
.text {
stroke-width : 0;
stroke : none;
fill : black;
font-size : 15px;
font-style : italic;
}
.rect {
stroke : none;
stroke-width : 0;
}
]]>
</style>
<rect class="rect" x="0" y="0" width="50" height="100" fill="LightBlue"/>
<rect class="rect" x="50" y="0" width="50" height="100" fill="LightGreen"/><!-- AntiqueWhite LightCyan -->
<line class="line" x1="25" y1="70" x2="75" y2="70"/>
<line class="line" x1="50" y1="10" x2="50" y2="90"/>
<path fill="none" stroke="black" d="M 50,65 l 5,0 l 0,5"/>
<circle class="circle" cx="25" cy="70" r="2"/>
<circle class="circle" cx="75" cy="70" r="2"/>
<text class="text" x="14" y="70">p</text>
<text class="text" x="80" y="70">q</text>
<text class="text" x="5" y="20">H<tspan dy="0.2em" style="font-size : smaller">pq</tspan></text>
<text class="text" x="75" y="20">H<tspan dy="0.2em" style="font-size : smaller">qp</tspan></text>
<!--
Creation timestamp (ISO 8601) 2015-02-06T05:39:42+00:00.
2015-02-06
first release
-->
</svg>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment