NameRecord nr = new NameRecord(); nr.initData(ttf, data); nameRecords.add(nr); if (nr.getStringOffset() > getLength()) nr.setString(null); continue; data.seek(getOffset() + (2*3)+numberOfNameRecords*2*6+nr.getStringOffset()); int platform = nr.getPlatformId(); int encoding = nr.getPlatformEncodingId(); Charset charset = Charsets.ISO_8859_1; if (platform == NameRecord.PLATFORM_WINDOWS && (encoding == NameRecord.ENCODING_WINDOWS_SYMBOL || encoding == NameRecord.ENCODING_WINDOWS_UNICODE_BMP)) String string = data.readString(nr.getStringLength(), charset); nr.setString(string); Map<Integer, Map<Integer, Map<Integer, String>>> platformLookup = lookupTable.get(nr.getNameId()); if (platformLookup == null) lookupTable.put(nr.getNameId(), platformLookup); Map<Integer, Map<Integer, String>> encodingLookup = platformLookup.get(nr.getPlatformId()); if (encodingLookup == null) platformLookup.put(nr.getPlatformId(), encodingLookup); Map<Integer, String> languageLookup = encodingLookup.get(nr.getPlatformEncodingId());
private boolean shouldCopyNameRecord(NameRecord nr) { return nr.getPlatformId() == NameRecord.PLATFORM_WINDOWS && nr.getPlatformEncodingId() == NameRecord.ENCODING_WINDOWS_UNICODE_BMP && nr.getLanguageId() == NameRecord.LANGUGAE_WINDOWS_EN_US && nr.getNameId() >= 0 && nr.getNameId() < 7; }
if (nr.getNameId() == NameRecord.NAME_FONT_FAMILY_NAME) { metadata.set(AdobeFontMetricParser.MET_FONT_FAMILY_NAME, nr.getString()); if (nr.getNameId() == NameRecord.NAME_FONT_SUB_FAMILY_NAME) { metadata.set(AdobeFontMetricParser.MET_FONT_SUB_FAMILY_NAME, nr.getString()); if (nr.getNameId() == NameRecord.NAME_FULL_FONT_NAME) { metadata.set(AdobeFontMetricParser.MET_FONT_NAME, nr.getString()); metadata.set(TikaCoreProperties.TITLE, nr.getString()); if (nr.getNameId() == NameRecord.NAME_POSTSCRIPT_NAME) { metadata.set(AdobeFontMetricParser.MET_PS_NAME, nr.getString()); if (nr.getNameId() == NameRecord.NAME_COPYRIGHT) { metadata.set("Copyright", nr.getString()); if (nr.getNameId() == NameRecord.NAME_TRADEMARK) { metadata.set("Trademark", nr.getString());
public void loadNamesFromFile() { try { BufferedReader stream = new BufferedReader(new FileReader("Data/boysnames.txt")); String currentLine =""; int i = 0; while(curentLine = stram.readLine()) { String [] record = currentLine.split(";"); NameRecord = name = new NameRecord(record[0], Integer.parseInt(record[1]); boyNames[i] = name; i++; } } catch (Exception e) { System.out.println("File not found"); } }
int platform = record.getPlatformId(); int encoding = record.getPlatformEncodingId(); String charset = "ISO-8859-1"; String value = record.getString(); if (record.getNameId() == 6 && prefix != null) writeUint16(out, nr.getPlatformId()); writeUint16(out, nr.getPlatformEncodingId()); writeUint16(out, nr.getLanguageId()); writeUint16(out, nr.getNameId()); writeUint16(out, names[j].length); writeUint16(out, offset);
if (nr.getNameId() == NameRecord.NAME_FONT_FAMILY_NAME) { metadata.set(AdobeFontMetricParser.MET_FONT_FAMILY_NAME, nr.getString()); if (nr.getNameId() == NameRecord.NAME_FONT_SUB_FAMILY_NAME) { metadata.set(AdobeFontMetricParser.MET_FONT_SUB_FAMILY_NAME, nr.getString()); if (nr.getNameId() == NameRecord.NAME_FULL_FONT_NAME) { metadata.set(AdobeFontMetricParser.MET_FONT_NAME, nr.getString()); metadata.set(TikaCoreProperties.TITLE, nr.getString()); if (nr.getNameId() == NameRecord.NAME_POSTSCRIPT_NAME) { metadata.set(AdobeFontMetricParser.MET_PS_NAME, nr.getString()); if (nr.getNameId() == NameRecord.NAME_COPYRIGHT) { metadata.set("Copyright", nr.getString()); if (nr.getNameId() == NameRecord.NAME_TRADEMARK) { metadata.set("Trademark", nr.getString());
public class Names { try { ArrayList<NameRecord> boyNames = new ArrayList<>(); public void loadNamesFromFile() { File file = new File("Data/boysnames.txt"); Scanner sc = new Scanner(file); while(sc.hasNextLine()) { boyNames.add(new NameRecord(sc.next(), sc.nextInt())); } sc.close(); } } catch(IOException e) { System.err.println(e); } }
NameRecord nr = new NameRecord(); nr.initData(ttf, data); nameRecords.add(nr); if (nr.getStringOffset() > getLength()) nr.setString(null); continue; data.seek(getOffset() + (2*3)+numberOfNameRecords*2*6+nr.getStringOffset()); int platform = nr.getPlatformId(); int encoding = nr.getPlatformEncodingId(); Charset charset = Charsets.ISO_8859_1; if (platform == NameRecord.PLATFORM_WINDOWS && (encoding == NameRecord.ENCODING_WINDOWS_SYMBOL || encoding == NameRecord.ENCODING_WINDOWS_UNICODE_BMP)) String string = data.readString(nr.getStringLength(), charset); nr.setString(string); Map<Integer, Map<Integer, Map<Integer, String>>> platformLookup = lookupTable.get(nr.getNameId()); if (platformLookup == null) lookupTable.put(nr.getNameId(), platformLookup); Map<Integer, Map<Integer, String>> encodingLookup = platformLookup.get(nr.getPlatformId()); if (encodingLookup == null) platformLookup.put(nr.getPlatformId(), encodingLookup); Map<Integer, String> languageLookup = encodingLookup.get(nr.getPlatformEncodingId());
private boolean shouldCopyNameRecord(NameRecord nr) { return nr.getPlatformId() == NameRecord.PLATFORM_WINDOWS && nr.getPlatformEncodingId() == NameRecord.ENCODING_WINDOWS_UNICODE_BMP && nr.getLanguageId() == NameRecord.LANGUGAE_WINDOWS_EN_US && nr.getNameId() >= 0 && nr.getNameId() < 7; }
if (nr.getNameId() == NameRecord.NAME_FONT_FAMILY_NAME) { metadata.set(AdobeFontMetricParser.MET_FONT_FAMILY_NAME, nr.getString()); if (nr.getNameId() == NameRecord.NAME_FONT_SUB_FAMILY_NAME) { metadata.set(AdobeFontMetricParser.MET_FONT_SUB_FAMILY_NAME, nr.getString()); if (nr.getNameId() == NameRecord.NAME_FULL_FONT_NAME) { metadata.set(AdobeFontMetricParser.MET_FONT_NAME, nr.getString()); metadata.set(TikaCoreProperties.TITLE, nr.getString()); if (nr.getNameId() == NameRecord.NAME_POSTSCRIPT_NAME) { metadata.set(AdobeFontMetricParser.MET_PS_NAME, nr.getString()); if (nr.getNameId() == NameRecord.NAME_COPYRIGHT) { metadata.set("Copyright", nr.getString()); if (nr.getNameId() == NameRecord.NAME_TRADEMARK) { metadata.set("Trademark", nr.getString());
Scanner boys = new Scanner(new File("Data/boys.txt")); int a,i,n=0,c,b; String con = "", x; //con holds all names //reading the names while(boys.hasNext()) con+= boys.next()+" "; b = con.split(" ").length; //b = total number of names in the file for(i=0; i<b; i++){ x = con.split(" ")[i]; if(!x.equals("*")){ c = 0; a = 0; //counting frequency of x in con while(con.indexOf(x, a) != -1){ c++; a = con.indexOf(x, a) + x.length() + 1; } //adding name and frequency to array boyNames[n++] = new NameRecord(x, c); con = con.replaceAll(x, "*"); //removing all instances of x from con } }
NameRecord nr = new NameRecord(); nr.initData(ttf, data); nameRecords.add(nr); if (nr.getStringOffset() > getLength()) nr.setString(null); continue; data.seek(getOffset() + (2*3)+numberOfNameRecords*2*6+nr.getStringOffset()); int platform = nr.getPlatformId(); int encoding = nr.getPlatformEncodingId(); Charset charset = Charsets.ISO_8859_1; if (platform == NameRecord.PLATFORM_WINDOWS && (encoding == NameRecord.ENCODING_WINDOWS_SYMBOL || encoding == NameRecord.ENCODING_WINDOWS_UNICODE_BMP)) String string = data.readString(nr.getStringLength(), charset); nr.setString(string); Map<Integer, Map<Integer, Map<Integer, String>>> platformLookup = lookupTable.get(nr.getNameId()); if (platformLookup == null) lookupTable.put(nr.getNameId(), platformLookup); Map<Integer, Map<Integer, String>> encodingLookup = platformLookup.get(nr.getPlatformId()); if (encodingLookup == null) platformLookup.put(nr.getPlatformId(), encodingLookup); Map<Integer, String> languageLookup = encodingLookup.get(nr.getPlatformEncodingId());
private boolean shouldCopyNameRecord(NameRecord nr) { return nr.getPlatformId() == NameRecord.PLATFORM_WINDOWS && nr.getPlatformEncodingId() == NameRecord.ENCODING_WINDOWS_UNICODE_BMP && nr.getLanguageId() == NameRecord.LANGUGAE_WINDOWS_EN_US && nr.getNameId() >= 0 && nr.getNameId() < 7; }
String readFile() { StringBuilder sb = new StringBuilder(); sb.append("FIND RESULTS FOR Trinity\n\n"); sb.append("Decade\tRank\n"); sb.append("------\t-----\n"); try { String inputLine; Scanner inFile = new Scanner (new File ("baby-names.txt")); int i = 0; int num = inFile.nextInt(); nameList = new NameRecord[num]; while ( inFile.hasNext() ) { inputLine = inFile.nextLine(); System.out.println(inputLine); nameList[i] = new NameRecord(inputLine); sb.append(nameList[i].getDecade() + "\t" + nameList[i].getRank() + "\n"); i++ ; } } catch(IOException io) { System.out.println(io) ; } return sb.toString(); }
int platform = record.getPlatformId(); int encoding = record.getPlatformEncodingId(); String charset = "ISO-8859-1"; String value = record.getString(); if (record.getNameId() == 6 && prefix != null) writeUint16(out, nr.getPlatformId()); writeUint16(out, nr.getPlatformEncodingId()); writeUint16(out, nr.getLanguageId()); writeUint16(out, nr.getNameId()); writeUint16(out, names[j].length); writeUint16(out, offset);
int platform = record.getPlatformId(); int encoding = record.getPlatformEncodingId(); String charset = "ISO-8859-1"; String value = record.getString(); if (record.getNameId() == 6 && prefix != null) writeUint16(out, nr.getPlatformId()); writeUint16(out, nr.getPlatformEncodingId()); writeUint16(out, nr.getLanguageId()); writeUint16(out, nr.getNameId()); writeUint16(out, names[j].length); writeUint16(out, offset);