Skip to content

Commit

Permalink
[426] Use the font defined in the GMF node to compute label size
Browse files Browse the repository at this point in the history
Bug: #426
  • Loading branch information
lredor committed Jul 15, 2024
1 parent 0eb5b9b commit f3ec948
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@
import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.FontStyle;
import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Location;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
import org.eclipse.gmf.runtime.notation.Size;
import org.eclipse.gmf.runtime.notation.Style;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
import org.eclipse.jface.resource.ImageDescriptor;
Expand Down Expand Up @@ -1086,7 +1088,16 @@ public static Dimension getLabelDimension(Node node, Dimension defaultDimension)
if (!new DDiagramElementQuery(dDiagramElement).isLabelHidden()) {
if (siriusStyle instanceof BasicLabelStyle) {
BasicLabelStyle bls = (BasicLabelStyle) siriusStyle;
Font defaultFont = VisualBindingManager.getDefault().getFontFromLabelStyle(bls, (String) viewQuery.getDefaultValue(NotationPackage.Literals.FONT_STYLE__FONT_NAME));
String fontName = (String) viewQuery.getDefaultValue(NotationPackage.Literals.FONT_STYLE__FONT_NAME);
Style style = node.getStyle(NotationPackage.eINSTANCE.getFontStyle());
if (style instanceof FontStyle) {
String currentFontName = ((FontStyle) style).getFontName();
if (currentFontName != null && !currentFontName.isEmpty()) {
// Use the defined font name in the node if it is defined.
fontName = currentFontName;
}
}
Font defaultFont = VisualBindingManager.getDefault().getFontFromLabelStyle(bls, fontName);
try {
labelSize = FigureUtilities.getStringExtents(dDiagramElement.getName(), defaultFont);
if (bls.isShowIcon()) {
Expand Down

0 comments on commit f3ec948

Please sign in to comment.