Implement font sets.
This commit is contained in:
parent
984f136351
commit
c529bf7b06
4 changed files with 72 additions and 4 deletions
|
@ -145,11 +145,12 @@ void text_layout::shape_text(text_line_ptr line)
|
|||
{
|
||||
face_set_ptr face_set = font_manager_.get_face_set(itr->format->face_name, itr->format->fontset);
|
||||
face_set->set_character_sizes(itr->format->text_size);
|
||||
face_ptr face = *(face_set->begin()); //TODO: Implement font sets correctly
|
||||
font_face_set::iterator face_itr = face_set->begin(), face_end = face_set->end();
|
||||
for (; face_itr != face_end; face_itr++)
|
||||
{
|
||||
face_ptr face = *face_itr;
|
||||
text_shaping shaper(face->get_face()); //TODO: Make this more efficient by caching this object in font_face
|
||||
|
||||
line->update_max_char_height(face->get_char_height());
|
||||
|
||||
shaper.process_text(text, itr->start, itr->end, itr->rtl == UBIDI_RTL, itr->script);
|
||||
hb_buffer_t *buffer = shaper.get_buffer();
|
||||
|
||||
|
@ -158,6 +159,24 @@ void text_layout::shape_text(text_line_ptr line)
|
|||
hb_glyph_info_t *glyphs = hb_buffer_get_glyph_infos(buffer, NULL);
|
||||
hb_glyph_position_t *positions = hb_buffer_get_glyph_positions(buffer, NULL);
|
||||
|
||||
bool font_has_all_glyphs = true;
|
||||
/* Check if all glyphs are valid. */
|
||||
for (unsigned i=0; i<num_glyphs; i++)
|
||||
{
|
||||
if (!glyphs[i].codepoint)
|
||||
{
|
||||
font_has_all_glyphs = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!font_has_all_glyphs)
|
||||
{
|
||||
//Try next font in fontset
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (unsigned i=0; i<num_glyphs; i++)
|
||||
{
|
||||
glyph_info tmp;
|
||||
|
@ -174,6 +193,9 @@ void text_layout::shape_text(text_line_ptr line)
|
|||
|
||||
line->add_glyph(tmp);
|
||||
}
|
||||
line->update_max_char_height(face->get_char_height());
|
||||
break; //When we reach this point the current font had all glyphs.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
BIN
tests/visual_tests/images/hb-fontsets-800-reference.png
Normal file
BIN
tests/visual_tests/images/hb-fontsets-800-reference.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
45
tests/visual_tests/styles/hb-fontsets.xml
Normal file
45
tests/visual_tests/styles/hb-fontsets.xml
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map>
|
||||
<Map background-color="white" srs="+proj=latlong +datum=WGS84">
|
||||
<Layer name="layer" srs="+proj=latlong +datum=WGS84">
|
||||
<StyleName>My Style</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="type">osm</Parameter>
|
||||
<Parameter name="file">../data/points.osm</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
<FontSet name="dejavu-first">
|
||||
<Font face-name="DejaVu Sans Book" />
|
||||
<Font face-name="Khmer OS Regular" />
|
||||
</FontSet>
|
||||
|
||||
<FontSet name="khmeros-first">
|
||||
<Font face-name="Khmer OS Regular" />
|
||||
<Font face-name="DejaVu Sans Book" />
|
||||
</FontSet>
|
||||
|
||||
|
||||
<Style name="My Style">
|
||||
<Rule>
|
||||
<Filter>[nr] = "2"</Filter>
|
||||
<TextSymbolizer face-name="Khmer OS Regular" size="36" placement="point" dy="-16">"A:ស្ត្រី"</TextSymbolizer>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="9" placement="point" dy="16">"Khmer OS Regular"</TextSymbolizer>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[nr] = "4"</Filter>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="36" placement="point" dy="-16">"B:ស្ត្រី"</TextSymbolizer>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="9" placement="point" dy="16">"DejaVu Sans Book"</TextSymbolizer>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[nr] = "6"</Filter>
|
||||
<TextSymbolizer fontset-name="dejavu-first" size="36" placement="point" dy="-16">"C:ស្ត្រី"</TextSymbolizer>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="9" placement="point" dy="16">"FontSet: DejaVu first"</TextSymbolizer>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[nr] = "8"</Filter>
|
||||
<TextSymbolizer fontset-name="khmeros-first" size="36" placement="point" dy="-16">"D:ស្ត្រី"</TextSymbolizer>
|
||||
<TextSymbolizer face-name="DejaVu Sans Book" size="9" placement="point" dy="16">"FontSet: Khmer OS first"</TextSymbolizer>
|
||||
</Rule>
|
||||
</Style>
|
||||
</Map>
|
|
@ -46,7 +46,8 @@ files = [
|
|||
{'name': "jalign-auto", 'sizes': [(200, 200)]},
|
||||
{'name': "line-offset", 'sizes':[(900, 250)],
|
||||
'bbox': mapnik.Box2d(-5.192, 50.189, -5.174, 50.195)},
|
||||
{'name': "orientation", 'sizes': [(800, 200)]}
|
||||
{'name': "orientation", 'sizes': [(800, 200)]},
|
||||
{'name': "hb-fontsets", 'sizes': [(800, 200)]}
|
||||
]
|
||||
|
||||
def render(filename, width, height, bbox, quiet=False):
|
||||
|
|
Loading…
Reference in a new issue