mapnik-ios-framework icon indicating copy to clipboard operation
mapnik-ios-framework copied to clipboard

Unable to load fonts

Open macvillanda opened this issue 11 years ago • 2 comments

Hello, I have been testing/ playing around with the IOS framework for Mapnik. If you could kindly help me on the issue of loading the fonts. I always get the error:

Unable to find specified font face 'DejaVu Sans Book'

my style.xml is as follows:

<Style name="My Style">
    <Rule>
        <PolygonSymbolizer fill="#f2eff9" />
        <LineSymbolizer stroke="rgb(50%,50%,50%)" stroke-width="0.1" />
        <TextSymbolizer face-name="DejaVu Sans Book" size="10" fill="black" name="[name]"></TextSymbolizer>
    </Rule>
</Style>

<Layer name="world" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>My Style</StyleName>
    <Datasource>
        <Parameter name="type">shape</Parameter>
        <Parameter name="file">roads.shp</Parameter>
        <Parameter name="base">RESOURCE_PATH</Parameter>
    </Datasource>
</Layer>

Do I need to register fonts? how? Could you provide simple example to use a TextSymbolizer.

Thank you

macvillanda avatar Aug 27 '13 13:08 macvillanda

I don't think I got fonts working either. It should be possible but it probably involves chasing the exact location mapnik tries to fopen() the font file and then manipulating that code to make sure there is no directory attached to the file location. Congratulations on making it this far though!

PaulWagener avatar Aug 29 '13 06:08 PaulWagener

Hello, Thanks for the reply. I got it working by registering the font by:

mapnik::freetype_engine::register_font("path/to/font.ttf");

It needs the exact location of the ttf file. It does render the text but the placement is "point". By documentation of TextSymbolizer i use:

<Style name="My Style">
    <Rule>
        <PolygonSymbolizer fill="#f2eff9" />
        <LineSymbolizer stroke="rgb(50%,50%,50%)" stroke-width="0.1" />
        <TextSymbolizer face-name="DejaVu Sans Book" size="10" fill="black" name="[name]" placement="line" allow-overlap="false"></TextSymbolizer>
    </Rule>
</Style>

<Layer name="world" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
    <StyleName>My Style</StyleName>
    <Datasource>
        <Parameter name="type">shape</Parameter>
        <Parameter name="file">roads.shp</Parameter>
        <Parameter name="base">RESOURCE_PATH</Parameter>
    </Datasource>
</Layer>

but generates an error:

Failed to parse attribute 'placement'. Expected one of [point, line, vertex, interior] but got 'line' in style 'MyStyle'

It was solved by building mapnik and all dependencies using libstdc++/clang++

according to https://github.com/mapnik/mapnik-support/issues/12

I am not sure how to do it. Any help?

Thanks

macvillanda avatar Aug 29 '13 10:08 macvillanda