1

I am trying to add place names to a map with GeoServer. This works as expected, except that I am unable to add a fallback font family. When I try to add one, the displayed names use a serif font, suggesting that the font family information is being ignored entirely. This is a code snippet:

<sld:TextSymbolizer>
            <sld:Label>
              <ogc:PropertyName>name</ogc:PropertyName>
            </sld:Label>
            <sld:Font>
              <sld:CssParameter name="font-family">Noto Sans</sld:CssParameter>
              <sld:CssParameter name="font-size">34</sld:CssParameter>
            </sld:Font>
            <sld:LabelPlacement>
              <sld:PointPlacement>
                <sld:AnchorPoint>
                  <sld:AnchorPointX>0.5</sld:AnchorPointX>
                  <sld:AnchorPointY>1</sld:AnchorPointY>
                </sld:AnchorPoint>
                <sld:Displacement>
                  <sld:DisplacementX>0</sld:DisplacementX>
                  <sld:DisplacementY>-7</sld:DisplacementY>
                </sld:Displacement>
              </sld:PointPlacement>
            </sld:LabelPlacement>

            <Halo>
              <Radius>1.5</Radius>
              <Fill>
                <CssParameter name="fill">#FFFFFF</CssParameter>
                <CssParameter name="fill-opacity">0.75</CssParameter>
              </Fill>
            </Halo>

            <sld:Fill>
              <sld:CssParameter name="fill">#000000</sld:CssParameter>
            </sld:Fill>
            <sld:Priority>
              <ogc:Sub>
                <ogc:Literal>100</ogc:Literal>
                <ogc:PropertyName>labelrank</ogc:PropertyName>
              </ogc:Sub>
            </sld:Priority>


            <sld:VendorOption name="conflictResolution">true</sld:VendorOption>
            <sld:VendorOption name="maxDisplacement">18</sld:VendorOption>
            <sld:VendorOption name="spaceAround">6</sld:VendorOption>
            <sld:VendorOption name="autoWrap">60</sld:VendorOption>
          </sld:TextSymbolizer>

I have successfully installed both Lato and Noto Sans, and using either of these individually works as expected. But if I try something like the following I get neither (and instead just a system serif font), e.g.

<sld:CssParameter name="font-family">Lato, Noto Sans</sld:CssParameter>

How can I correctly specify a fallback font family?

I'm using GeoServer vn 2.25.3

1 Answer 1

0

You can just list all the font families one after the other:

  <CssParameter name="font-family">Cantarell Light</CssParameter>
  <CssParameter name="font-family">Times New Roman</CssParameter>

GeoServer will pick the first it recognises.

1
  • Perfect, thanks!
    – Mython
    Commented Oct 4 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.