diff options
author | Chris Loer <chris.loer@gmail.com> | 2017-11-28 15:33:19 -0800 |
---|---|---|
committer | Chris Loer <chris.loer@gmail.com> | 2017-11-29 13:50:15 -0800 |
commit | 83d6513ca6d2f00507a3e25f5aa68e9d7390b910 (patch) | |
tree | 39564965962d2a68be12ad0d76cef0079e848a01 | |
parent | 132e13fe9a4b789a57574c6f2ca168bbb50d6a06 (diff) | |
download | qtlocation-mapboxgl-83d6513ca6d2f00507a3e25f5aa68e9d7390b910.tar.gz |
Fix unit tests.
-rw-r--r-- | platform/darwin/src/local_glyph_rasterizer.mm | 19 | ||||
-rw-r--r-- | platform/ios/config.cmake | 1 | ||||
-rw-r--r-- | platform/macos/config.cmake | 1 | ||||
-rw-r--r-- | src/mbgl/text/glyph_manager.hpp | 2 |
4 files changed, 15 insertions, 8 deletions
diff --git a/platform/darwin/src/local_glyph_rasterizer.mm b/platform/darwin/src/local_glyph_rasterizer.mm index f12be78daa..a5edecb097 100644 --- a/platform/darwin/src/local_glyph_rasterizer.mm +++ b/platform/darwin/src/local_glyph_rasterizer.mm @@ -22,16 +22,21 @@ namespace mbgl { */ using CTFontDescriptorRefHandle = CFHandle<CTFontDescriptorRef, CFTypeRef, CFRelease>; -using CTFontRefHandle = CFHandle<CTFontRef, CFTypeRef, CFRelease>; using CTLineRefHandle = CFHandle<CTLineRef, CFTypeRef, CFRelease>; class LocalGlyphRasterizer::Impl { public: - Impl(CTFontRef fontHandle) - : font(fontHandle) + Impl(CTFontRef font_) + : font(font_) {} + + ~Impl() { + if (font) { + CFRelease(font); + } + } - CTFontRefHandle font; + CTFontRef font; }; LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string> fontFamily) @@ -56,7 +61,7 @@ LocalGlyphRasterizer::~LocalGlyphRasterizer() bool LocalGlyphRasterizer::canRasterizeGlyph(const FontStack&, GlyphID glyphID) { // TODO: This is a rough approximation of the set of glyphs that will work with fixed glyph metrics // Either narrow this down to be conservative, or actually extract glyph metrics in rasterizeGlyph - return *(impl->font) && util::i18n::allowsIdeographicBreaking(glyphID); + return impl->font && util::i18n::allowsIdeographicBreaking(glyphID); } // TODO: In theory we should be able to transform user-coordinate bounding box and advance @@ -137,7 +142,7 @@ PremultipliedImage drawGlyphBitmap(GlyphID glyphID, CTFontRef font, Size size) { Glyph LocalGlyphRasterizer::rasterizeGlyph(const FontStack&, GlyphID glyphID) { Glyph fixedMetrics; - if (!*(impl->font)) { + if (!impl->font) { return fixedMetrics; } @@ -151,7 +156,7 @@ Glyph LocalGlyphRasterizer::rasterizeGlyph(const FontStack&, GlyphID glyphID) { fixedMetrics.metrics.top = -1; fixedMetrics.metrics.advance = 24; - PremultipliedImage rgbaBitmap = drawGlyphBitmap(glyphID, *(impl->font), size); + PremultipliedImage rgbaBitmap = drawGlyphBitmap(glyphID, impl->font, size); // Copy alpha values from RGBA bitmap into the AlphaImage output fixedMetrics.bitmap = AlphaImage(size); diff --git a/platform/ios/config.cmake b/platform/ios/config.cmake index b08138c9b9..1caf372b25 100644 --- a/platform/ios/config.cmake +++ b/platform/ios/config.cmake @@ -72,6 +72,7 @@ macro(mbgl_platform_core) target_link_libraries(mbgl-core PUBLIC "-lz" PUBLIC "-framework Foundation" + PUBLIC "-framework CoreText" PUBLIC "-framework CoreGraphics" PUBLIC "-framework OpenGLES" PUBLIC "-framework ImageIO" diff --git a/platform/macos/config.cmake b/platform/macos/config.cmake index 83b618e379..3b7d112455 100644 --- a/platform/macos/config.cmake +++ b/platform/macos/config.cmake @@ -62,6 +62,7 @@ macro(mbgl_platform_core) target_link_libraries(mbgl-core PUBLIC "-lz" PUBLIC "-framework Foundation" + PUBLIC "-framework CoreText" PUBLIC "-framework CoreGraphics" PUBLIC "-framework OpenGL" PUBLIC "-framework ImageIO" diff --git a/src/mbgl/text/glyph_manager.hpp b/src/mbgl/text/glyph_manager.hpp index d34ec2a61e..84db2c4be5 100644 --- a/src/mbgl/text/glyph_manager.hpp +++ b/src/mbgl/text/glyph_manager.hpp @@ -25,7 +25,7 @@ public: class GlyphManager : public util::noncopyable { public: - GlyphManager(FileSource&, std::unique_ptr<LocalGlyphRasterizer>); + GlyphManager(FileSource&, std::unique_ptr<LocalGlyphRasterizer> = std::make_unique<LocalGlyphRasterizer>(optional<std::string>())); ~GlyphManager(); // Workers send a `getGlyphs` message to the main thread once they have determined |