Browse Source

Bring back PPI-based units

SiPlus 11 years ago
parent
commit
64e2b25797
1 changed files with 17 additions and 0 deletions
  1. 17 0
      Source/Core/ElementStyle.cpp

+ 17 - 0
Source/Core/ElementStyle.cpp

@@ -363,6 +363,23 @@ float ElementStyle::ResolveProperty(const Property* property, float base_value)
 		return property->value.Get< float >();
 	}
 
+	// Values based on pixels-per-inch.
+	if (property->unit & Property::PPI_UNIT)
+	{
+		float inch = property->value.Get< float >() * element->GetRenderInterface()->GetPixelsPerInch();
+		
+		if (property->unit & Property::IN) // inch
+			return inch;
+		if (property->unit & Property::CM) // centimeter
+			return inch * (1.0f / 2.54f);
+		if (property->unit & Property::MM) // millimeter
+			return inch * (1.0f / 25.4f);
+		if (property->unit & Property::PT) // point
+			return inch * (1.0f / 72.0f);
+		if (property->unit & Property::PC) // pica
+			return inch * (1.0f / 6.0f);
+	}
+
 	// We're not a numeric property; return 0.
 	return 0.0f;
 }