@@ -225,37 +225,40 @@ private static int CharacteristicsSimilarity(String fontName, FontCharacteristic
225
225
score -= EXPECTED_FONT_IS_NOT_MONOSPACED_AWARD ;
226
226
}
227
227
}
228
- FontProgramDescriptor descriptor = fontInfo . GetDescriptor ( ) ;
229
- // Note, aliases are custom behaviour, so in FontSelector will find only exact name,
230
- // it should not be any 'contains' with aliases.
231
- bool checkContains = true ;
232
- if ( fontName . Equals ( descriptor . GetFullNameLowerCase ( ) ) ) {
233
- // the next condition can be simplified. it's been written that way to prevent mistakes if the condition is moved.
234
- score += checkContains ? FULL_NAME_EQUALS_AWARD : EQUALS_ADDITIONAL_AWARD ;
235
- checkContains = false ;
236
- }
237
- if ( fontName . Equals ( descriptor . GetFontNameLowerCase ( ) ) ) {
238
- score += checkContains ? FONT_NAME_EQUALS_AWARD : EQUALS_ADDITIONAL_AWARD ;
239
- checkContains = false ;
240
- }
241
- if ( fontName . Equals ( fontInfo . GetAlias ( ) ) ) {
242
- score += checkContains ? ALIAS_EQUALS_AWARD : EQUALS_ADDITIONAL_AWARD ;
243
- checkContains = false ;
244
- }
245
- if ( checkContains ) {
246
- bool conditionHasBeenSatisfied = false ;
247
- if ( descriptor . GetFullNameLowerCase ( ) . Contains ( fontName ) ) {
228
+ // empty font name means that font family wasn't detected. in that case one should compare only style characteristics
229
+ if ( ! "" . Equals ( fontName ) ) {
230
+ FontProgramDescriptor descriptor = fontInfo . GetDescriptor ( ) ;
231
+ // Note, aliases are custom behaviour, so in FontSelector will find only exact name,
232
+ // it should not be any 'contains' with aliases.
233
+ bool checkContains = true ;
234
+ if ( fontName . Equals ( descriptor . GetFullNameLowerCase ( ) ) ) {
248
235
// the next condition can be simplified. it's been written that way to prevent mistakes if the condition is moved.
249
- score += conditionHasBeenSatisfied ? FULL_NAME_CONTAINS_AWARD : CONTAINS_ADDITIONAL_AWARD ;
250
- conditionHasBeenSatisfied = true ;
236
+ score += checkContains ? FULL_NAME_EQUALS_AWARD : EQUALS_ADDITIONAL_AWARD ;
237
+ checkContains = false ;
238
+ }
239
+ if ( fontName . Equals ( descriptor . GetFontNameLowerCase ( ) ) ) {
240
+ score += checkContains ? FONT_NAME_EQUALS_AWARD : EQUALS_ADDITIONAL_AWARD ;
241
+ checkContains = false ;
251
242
}
252
- if ( descriptor . GetFontNameLowerCase ( ) . Contains ( fontName ) ) {
253
- score += conditionHasBeenSatisfied ? FONT_NAME_CONTAINS_AWARD : CONTAINS_ADDITIONAL_AWARD ;
254
- conditionHasBeenSatisfied = true ;
243
+ if ( fontName . Equals ( fontInfo . GetAlias ( ) ) ) {
244
+ score += checkContains ? ALIAS_EQUALS_AWARD : EQUALS_ADDITIONAL_AWARD ;
245
+ checkContains = false ;
255
246
}
256
- if ( null != fontInfo . GetAlias ( ) && fontInfo . GetAlias ( ) . Contains ( fontName ) ) {
257
- score += conditionHasBeenSatisfied ? ALIAS_CONTAINS_AWARD : CONTAINS_ADDITIONAL_AWARD ;
258
- conditionHasBeenSatisfied = true ;
247
+ if ( checkContains ) {
248
+ bool conditionHasBeenSatisfied = false ;
249
+ if ( descriptor . GetFullNameLowerCase ( ) . Contains ( fontName ) ) {
250
+ // the next condition can be simplified. it's been written that way to prevent mistakes if the condition is moved.
251
+ score += conditionHasBeenSatisfied ? FULL_NAME_CONTAINS_AWARD : CONTAINS_ADDITIONAL_AWARD ;
252
+ conditionHasBeenSatisfied = true ;
253
+ }
254
+ if ( descriptor . GetFontNameLowerCase ( ) . Contains ( fontName ) ) {
255
+ score += conditionHasBeenSatisfied ? FONT_NAME_CONTAINS_AWARD : CONTAINS_ADDITIONAL_AWARD ;
256
+ conditionHasBeenSatisfied = true ;
257
+ }
258
+ if ( null != fontInfo . GetAlias ( ) && fontInfo . GetAlias ( ) . Contains ( fontName ) ) {
259
+ score += conditionHasBeenSatisfied ? ALIAS_CONTAINS_AWARD : CONTAINS_ADDITIONAL_AWARD ;
260
+ conditionHasBeenSatisfied = true ;
261
+ }
259
262
}
260
263
}
261
264
// this line is redundant. it's added to prevent mistakes if other condition is added.
0 commit comments