]> granicus.if.org Git - libass/commitdiff
directwrite: add 'width' attribute
authorGrigori Goronzy <greg@chown.ath.cx>
Sat, 23 May 2015 11:20:55 +0000 (13:20 +0200)
committerGrigori Goronzy <greg@chown.ath.cx>
Fri, 10 Jul 2015 08:42:41 +0000 (10:42 +0200)
This is required for proper font matching.

libass/ass_directwrite.cpp

index f00b7b8f1d52b5eca1a36af2d0ce4e87482ac19e..415afef0584d5a0188678cb5b33a9736e56a551f 100644 (file)
@@ -148,6 +148,11 @@ static void destroy_font(void *data)
        free(priv);
 }
 
+static int map_width(int stretch)
+{
+       return stretch * (100 / DWRITE_FONT_STRETCH_MEDIUM);
+}
+
 static void scan_fonts(IDWriteFactory *factory, ASS_FontProvider *provider)
 {
        HRESULT hr = S_OK;
@@ -187,6 +192,7 @@ static void scan_fonts(IDWriteFactory *factory, ASS_FontProvider *provider)
                                return;
                        
                        meta.weight = font->GetWeight();
+                       meta.width = map_width(font->GetStretch());
                        font->GetMetrics(&metrics);
                        style = font->GetStyle();
                        meta.slant =    (style==DWRITE_FONT_STYLE_NORMAL)? FONT_SLANT_NONE: