Browse Source

allow Oberon fontnames with more than one capital letter (e.g. PTSans12b.Scn.Fnt)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7612 8c9fc860-2736-0410-a75d-ab315db34111
eth.guenter 7 years ago
parent
commit
a4161f43a2
2 changed files with 11 additions and 9 deletions
  1. 2 5
      source/OberonFonts.Mod
  2. 9 4
      source/TextUtilities.Mod

+ 2 - 5
source/OberonFonts.Mod

@@ -217,14 +217,11 @@ TYPE
 	VAR f: Files.File;  ttfname: Name;  size, res: INTEGER;
 	VAR f: Files.File;  ttfname: Name;  size, res: INTEGER;
 	BEGIN
 	BEGIN
 		f := Files.Old( oname );
 		f := Files.Old( oname );
-		IF f # NIL THEN
-			f.Close;  RETURN TRUE
+		IF f # NIL THEN  RETURN TRUE
 		ELSE
 		ELSE
 			MakeTtfName( oname, ttfname, size, res );
 			MakeTtfName( oname, ttfname, size, res );
 			f := Files.Old( ttfname );
 			f := Files.Old( ttfname );
-			IF f # NIL THEN
-				f.Close;  RETURN TRUE
-			END;
+			IF f # NIL THEN  RETURN TRUE  END;
 			RETURN FALSE
 			RETURN FALSE
 		END
 		END
 	END Allocatable;
 	END Allocatable;

+ 9 - 4
source/TextUtilities.Mod

@@ -486,7 +486,7 @@ TYPE
 					reader.RawSInt(lib);
 					reader.RawSInt(lib);
 					IF lib = n THEN
 					IF lib = n THEN
 						reader.RawString(lName);
 						reader.RawString(lName);
-
+						
 						NEW(fonts[n]);
 						NEW(fonts[n]);
 						COPY(lName, fonts[n].name);
 						COPY(lName, fonts[n].name);
 						DecodeOberonFontName(lName, fonts[n].name, fonts[n].size, fonts[n].style);
 						DecodeOberonFontName(lName, fonts[n].name, fonts[n].size, fonts[n].style);
@@ -1233,7 +1233,7 @@ TYPE
 			IF (ch = Texts.LabelChar) THEN WriteLabel(r.object(Texts.LabelPiece).label^) END;
 			IF (ch = Texts.LabelChar) THEN WriteLabel(r.object(Texts.LabelPiece).label^) END;
 
 
 			RetrieveAttributes;
 			RetrieveAttributes;
-			(* PrintAttributes; *)
+			PrintAttributes;
 
 
 			IF (pStyle # NIL) & (pstylename # "Left") THEN WriteParagraph(pstylename) END;
 			IF (pStyle # NIL) & (pstylename # "Left") THEN WriteParagraph(pstylename) END;
 			WriteSpan(stylename);
 			WriteSpan(stylename);
@@ -2014,14 +2014,19 @@ BEGIN
 	text.ReleaseWrite
 	text.ReleaseWrite
 END StrToText;
 END StrToText;
 
 
+PROCEDURE IsDigit( ch: CHAR ): BOOLEAN;
+BEGIN
+	RETURN (ch >= '0') & (ch <= '9')
+END IsDigit;
+
 PROCEDURE DecodeOberonFontName(CONST name : ARRAY OF CHAR; VAR fn : ARRAY OF CHAR; VAR size : LONGINT; VAR style : SET);
 PROCEDURE DecodeOberonFontName(CONST name : ARRAY OF CHAR; VAR fn : ARRAY OF CHAR; VAR size : LONGINT; VAR style : SET);
 VAR i, j: LONGINT; sizeStr : ARRAY 8 OF CHAR;
 VAR i, j: LONGINT; sizeStr : ARRAY 8 OF CHAR;
 BEGIN
 BEGIN
 	(* first name in oberon font names is capital, all following are non-capital *)
 	(* first name in oberon font names is capital, all following are non-capital *)
 	fn[0] := name[0];
 	fn[0] := name[0];
-	i := 1; WHILE (name[i] >= "a") & (name[i] <= "z") DO fn[i] := name[i]; INC(i) END; fn[i] := 0X;
+	i := 1; WHILE ~IsDigit(name[i]) DO  fn[i] := name[i];  INC(i)  END;  fn[i] := 0X;
 	(* read the size *)
 	(* read the size *)
-	j := 0; WHILE (name[i] >= "0") & (name[i] <= "9") DO sizeStr[j] := name[i]; INC(j); INC(i) END; sizeStr[j] := 0X;
+	j := 0; WHILE IsDigit(name[i]) DO  sizeStr[j] := name[i];  INC(j); INC(i)  END;  sizeStr[j] := 0X;
 	Strings.StrToInt(sizeStr, size);
 	Strings.StrToInt(sizeStr, size);
 	style := {};
 	style := {};
 	CASE CAP(name[i]) OF
 	CASE CAP(name[i]) OF